package com.glg.book.dao;

import com.glg.book.model.BookInfo;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

@Component
public class BookDao {
    public List<BookInfo> mockData() {
        //理论上，该方法应从数据库中获取，当前采用 mock 的方式
        List<BookInfo> bookInfos = new ArrayList<>();
        for (int i = 1; i <= 15; i++) {
            BookInfo bookInfo = new BookInfo();
            bookInfo.setId(i);
            bookInfo.setName("左宗棠");
            bookInfo.setAuthor("张鸿福");
            bookInfo.setNum(i*2+1);
            bookInfo.setPrice(new BigDecimal(i*3));
            bookInfo.setPublishName("长江文艺出版社");
            if(i % 5 == 0) {
                bookInfo.setStatus(1);
                bookInfo.setStatusCN("不可借阅");
            }else {
                bookInfo.setStatus(2);
                bookInfo.setStatusCN("可借阅");
            }
            bookInfos.add(bookInfo);
        }
        return bookInfos;
    }
}
